<!DOCTYPE html>
<html>
	<head>
		<title><?php echo lang('site_title');?></title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<script src="http://oosrrnck1.bkt.clouddn.com/static/js/libs/jquery.min.js"></script>
		<script src="http://oosrrnck1.bkt.clouddn.com/static/js/libs/jquery.cookie.js"></script>
		
	</head>
	<body>
		<h1><?php echo $title; ?></h1>




		<div class="header" style="border: solid red thin;">
			<select id="changeLanguageBtn">
				<option value=""><?php echo lang('site_select_language');?></option>
				<!-- 
				<option value="english">English</option>
				<option value="chinese">简体中文</option>
				 -->
				<?php 
					$this->config->load('language');
					$spted = $this->config->item('supported_languages', 'multi_language');
					foreach ($spted as $v => $l) {
						printf("<option value=\"%s\">%s</option>\n", $v, $l);
					}
				?>
			</select>
		</div>
		<script type="text/javascript">
			<?php 
				$this->config->load('cookie');
				$lang_key = $this->config->item('lang_key');
			?>
			var cookieConfig = {
				langKey: "<?php echo $lang_key;?>"
			};

			$(document).ready(function(){

				var changeCookieProcessor = function(language) {
					$.removeCookie(cookieConfig.langKey);
					$.cookie(cookieConfig.langKey, language, {expires: 31});
				};

				var refreshPageProcessor = function() {
					location.href = location.href;
				};

				var changeLanguageHandler = function(event) {
					var _this = event.target;
					var language = $(_this).val();

					if(!language) return false;

					changeCookieProcessor(language);
					refreshPageProcessor();
				};

				$("#changeLanguageBtn").change(changeLanguageHandler);
			});

		</script>